<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>

    Fibonacci=[1,1,2,3,5,8,13,21];
    // getNthFibonacci(0) 返回值1
    // getNthFibonacci(4) 返回值5
    // 斐波那契数列的实现
    var getNthFibonacci=function(n){
        return n<2?1:getNthFibonacci(n-1)+getNthFibonacci(n-2);
    }
    for(var i=0;i<9;i++){
        console.log(getNthFibonacci(i));
    }
    </script>
</body>
</html>